import request from '@/utils/Request.js'

// 文章相关API
export const articleAPI = {
  // 获取主页文章列表
  getHomeArticleList() {
    return request({
      method: 'POST',
      url: '/article/getHomeList',
    })
  },

  // 获取文章列表
  getArticleList(data, options = {}) {
    return request({
      method: 'POST',
      url: '/article/getList',
      data,
      ...options
    })
  },

  // 获取文章详情
  getArticleDetail(data) {
    return request({
      method: 'POST',
      url: '/article/getDetail',
      data
    })
  },

  // 点赞文章
  likeArticle(data) {
    return request({
      method: 'POST',
      url: '/article/doLike',
      data
    })
  },

  // 发布文章
  publishArticle(data) {
    return request({
      method: 'POST',
      url: '/article/publishPost',
      data
    })
  },

  // 编辑文章
  editArticle(data) {
    return request({
      method: 'POST',
      url: '/article/editPost',
      data
    })
  },

  // 搜索文章
  searchArticles(data, options = {}) {
    return request({
      method: 'POST',
      url: '/article/search',
      data,
      ...options
    })
  },

  // 上传单张图片
  uploadImage(formData) {
    return request({
      method: 'POST',
      url: '/article/uploadImage',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  // 上传多张图片
  uploadMultipleImages(formData) {
    return request({
      method: 'POST',
      url: '/article/uploadMultipleImages',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  // 删除图片
  deleteImage(data) {
    return request({
      method: 'POST',
      url: '/article/deleteImage',
      data
    })
  },

  // 删除多张图片
  deleteMultipleImages(data) {
    return request({
      method: 'POST',
      url: '/article/deleteMultipleImages',
      data
    })
  },

  // 清理未使用的图片
  cleanupImages() {
    return request({
      method: 'POST',
      url: '/article/cleanupImages'
    })
  },

  // 获取清理统计信息
  getCleanupStats() {
    return request({
      method: 'POST',
      url: '/article/cleanupStats'
    })
  },

  // 获取板块信息
  getBoards() {
    return request({
      method: 'POST',
      url: '/article/getBoard'
    })
  },

  // 获取当日点赞前5帖子
  getDailyTopPost() {
    return request({
      method: 'POST',
      url: '/article/getDailyTop'
    })
  },

  // 删除帖子
  deletePost(data) {
    return request({
      method: 'POST',
      url: '/article/deletePost',
      data
    })
  }
}

export default articleAPI